let fn = async (room, { socket, reg, user, ERROR, ROOM_USERS, JOIN_ROOM }, topic) => {
    try {
        if (!user) return
        // 房间
        let r = await reg.rooms.joinRoom(room, user)
        // 当前用户信息
        let ua = user.toSender()
        // 发送房间用户列表给当前用户
        let members = r.members()
        await r.broadcast(u => {
            // 向房间广播事件
            u.socket.emit(JOIN_ROOM, ua)
            u.socket.emit(ROOM_USERS, members)
        })
    } catch ({ message }) {
        socket.emit(ERROR, {
                topic,
                data: message,
            })
    }
}

module.exports = fn